﻿using System;
using Mefisto.Core.Logging.Contracts;
using System.Dynamic;
using System.ComponentModel.Composition;

namespace Mefisto.Modules.Default.Logging
{
    [Export(typeof(ILoggingProvider))]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public class DefaultLoggingProvider : ILoggingProvider
    {
        #region Fields

        private ExpandoObject _loggingBag; 

        #endregion

        #region Properties

        /// <summary>
        /// Dynamic bag for passing parameters to methods
        /// <remarks>Should be of type IDictionary&lt;string, object&gt; for handling named parameters</remarks>
        /// </summary>
        public dynamic LoggingBag
        {
            get { return _loggingBag ?? (_loggingBag = new ExpandoObject()); }
            set { _loggingBag = value; }
        }

        #endregion

        #region Methods

        /// <summary>
        /// Method for logging message
        /// </summary>
        /// <param name="message">Message</param>
        /// <param name="applicationCode">Application code</param>
        public void LogMessage(string message, string applicationCode = "")
        {
            // TODO
        }

        /// <summary>
        /// Method for logging error
        /// </summary>
        /// <param name="error">Exception occured</param>
        /// <param name="applicationCode">Application code</param>
        public void LogError(Exception error, string applicationCode = "")
        {
            // TODO
        }

        /// <summary>
        /// Method for clearing the logging bag
        /// </summary>
        public void ClearLoggingBag()
        {
            _loggingBag = new ExpandoObject();
        }

        #endregion
    }
}